package com.iss.wyy.bean;

import com.iss.wyy.common.RequestMethod;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

/**
 * 封装请求信息
 */
public class Request {
    /**
     * 请求方法
     */
    private RequestMethod requestMethod;
    /**
     * 请求路径
     */
    private String requestPath;

    public Request(RequestMethod requestMethod, String requestPath) {
        this.requestMethod = requestMethod;
        this.requestPath = requestPath;
    }

    public RequestMethod getRequestMethod() {
        return requestMethod;
    }

    public void setRequestMethod(RequestMethod requestMethod) {
        this.requestMethod = requestMethod;
    }

    public String getRequestPath() {
        return requestPath;
    }

    public void setRequestPath(String requestPath) {
        this.requestPath = requestPath;
    }

    /**
     * 根据字段来构建哈希 和equals（只要字段的值相同，哈希和equals就相同）
     * 默认的哈希算法  要求同一个对象哈希才相等
     */
    @Override
    public int hashCode() {
        //System.out.println("哈希--------------"+HashCodeBuilder.reflectionHashCode(this));
        return HashCodeBuilder.reflectionHashCode(this);
    }

    @Override
    public boolean equals(Object obj) {
        return EqualsBuilder.reflectionEquals(this,obj);
    }
}
